package cn.terminus.data.customer.custompurposeroom.impl;

import cn.terminus.common.customer.bean.custompurposeroom.dto.*;
import cn.terminus.data.customer.custompurposeroom.dao.CustomPurposeRoomDao;
import cn.terminus.data.customer.custompurposeroom.mapper.CustomPurposeRoomMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomPurposeRoom)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:58
 */
@Repository
public class CustomPurposeRoomDaoImpl implements CustomPurposeRoomDao {
    @Resource
    private CustomPurposeRoomMapper customPurposeRoomMapper;

    @Override
    public Integer add(CustomPurposeRoomNewDto dto) {
        return customPurposeRoomMapper.add(dto);
    }

    @Override
    public Integer update(CustomPurposeRoomEditDto dto) {
        return customPurposeRoomMapper.update(dto);
    }

    @Override
    public List<CustomPurposeRoomResultDto> gets(CustomPurposeRoomGetsDto dto) {
        return customPurposeRoomMapper.gets(dto);
    }

    @Override
    public List<CustomPurposeRoomResultDto> query(CustomPurposeRoomQueryDto dto) {
        return customPurposeRoomMapper.query(dto);
    }

    @Override
    public Integer delete(CustomPurposeRoomDeleteDto dto) {
        return customPurposeRoomMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomPurposeRoomResultDto> page(CustomPurposeRoomQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomPurposeRoomResultDto> result = (Page<CustomPurposeRoomResultDto>) customPurposeRoomMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomPurposeRoomResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer addMulti(List<CustomPurposeRoomNewDto> customPurposeRoomNewDtoList) {
        return customPurposeRoomMapper.addMulti(customPurposeRoomNewDtoList);
    }

    @Override
    public List<CustomPurposeRoomResultDto> queryByContractIdsAndType(CustomRoomInfoGetDto roomInfoGetDto) {
        return customPurposeRoomMapper.queryByContractIdsAndType(roomInfoGetDto);
    }

    @Override
    public Integer deleteByContractIds(List<Long> contractIds) {
        return customPurposeRoomMapper.deleteByContractIds(contractIds);
    }

    @Override
    public Integer countContractRooms(List<Long> roomIds) {
        return customPurposeRoomMapper.countContractRooms(roomIds);
    }

    @Override
    public Integer deleteByCustomerId(CustomPurposeRoomDeleteDto dto) {
        return customPurposeRoomMapper.deleteByCustomerId(dto);
    }
}
